Skip to content

Use DefaultAzureCredential by default (#497)#550

Draft
janjagusch wants to merge 4 commits intodrivendataorg:masterfrom
janjagusch:feat/default-azure-credential
Draft

Use DefaultAzureCredential by default (#497)#550
janjagusch wants to merge 4 commits intodrivendataorg:masterfrom
janjagusch:feat/default-azure-credential

Conversation

@janjagusch
Copy link

@janjagusch janjagusch commented Feb 27, 2026

Summary

  • When account_url is provided without credential, automatically uses DefaultAzureCredential from azure-identity if installed (falls back to credential=None if not installed)
  • Adds support for AZURE_STORAGE_ACCOUNT_URL environment variable as a new fallback before raising MissingCredentialsError, mirroring the existing AZURE_STORAGE_CONNECTION_STRING pattern
  • Fixes minor docstring typos (""AZURE_STORAGE_CONNECTION_STRING" and raised raised)

Closes #497

Test plan

  • Existing test_azureblobpath_nocreds updated to also clear AZURE_STORAGE_ACCOUNT_URL env var
  • New test: DefaultAzureCredential used when account_url provided without credential
  • New test: explicit credential takes precedence over DefaultAzureCredential
  • New test: fallback to credential=None when azure-identity not installed
  • New test: AZURE_STORAGE_ACCOUNT_URL env var with .blob. URL
  • New test: AZURE_STORAGE_ACCOUNT_URL env var with .dfs. URL
  • New test: MissingCredentialsError still raised with no config
  • All 13 tests in test_azure_specific.py pass
  • All 16 tests in test_local.py pass

🤖 Generated with Claude Code

@janjagusch janjagusch force-pushed the feat/default-azure-credential branch 2 times, most recently from 03ea50f to e23d7e5 Compare February 27, 2026 21:32
…provided

When `account_url` is provided without `credential`, automatically use
`DefaultAzureCredential` from `azure-identity` if installed, bringing
Azure auth in line with how `GSClient` uses `google.auth.default()`.
Also adds support for `AZURE_STORAGE_ACCOUNT_URL` env var as a fallback.

Closes drivendataorg#497

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@janjagusch janjagusch force-pushed the feat/default-azure-credential branch from e23d7e5 to fafa0b7 Compare February 27, 2026 21:34
@janjagusch janjagusch marked this pull request as ready for review February 27, 2026 21:38
@janjagusch
Copy link
Author

@pjbull, hope you don't mind this agent-written PR. I reviewed the changes myself, making sure the diff remains minimal and plausible, and the changes look good to me. :)

@janjagusch
Copy link
Author

Friendly ping, @pjbull. Let me know what you think of this PR. :)

@janjagusch
Copy link
Author

@pjbull, friendly reminder. :)

Is there anything I can do to move this PR forward?

Copy link
Member

@pjbull pjbull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not sufficient review of an AI generated PR. Please don't submit AI PRs that don't follow the conventions of the repository, it creates an unnecessary burden for maintainers. We have extensive contributing docs.

Did you actually test this against a real Azure backend configured to use this path? A mock is not enough proof this works.

Also, please follow existing test patterns, not the MagicMock patterns in this PR. You should add azure mocks if you need them to the mock we already have and actually ensure the AzureClient object gets properties set on it correctly.

try:
from azure.identity import DefaultAzureCredential
except ImportError:
DefaultAzureCredential = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow existing convention and add to import block of azure dependencies above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The azure.identity import was intentionally left out of the big import block above, as azure-identity is an optional azure dependency, meaning you can use the azure blob client without it (you will just not be able to use identity-based authentication).

I've left a comment to make this clearer. Let me know if you prefer a different approach.

@janjagusch janjagusch marked this pull request as draft March 16, 2026 15:52
janjagusch and others added 3 commits March 16, 2026 16:58
Replace unittest.mock.MagicMock/patch patterns with the project's existing
MockBlobServiceClient and MockedDataLakeServiceClient, following the same
monkeypatch approach used in conftest.py. Tests now verify actual client
properties instead of asserting on mock calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

[project.optional-dependencies]
azure = ["azure-storage-blob>=12", "azure-storage-file-datalake>=12"]
azure = ["azure-storage-blob>=12", "azure-storage-file-datalake>=12", "azure-identity>=1"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, we could factor out azure-identity into its own dependency group. But I didn't want to overcomplicate things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use DefaultAzureCredential by default for Azure paths

2 participants